package ui.swing.dnd;

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.TransferHandler;

public class SimpleDragDropTest extends JFrame{

	public SimpleDragDropTest() {
		super("Drag & Drop Test");
		TransferHandler th = new TransferHandler("text");
		
		JPanel contentPane = (JPanel)getContentPane();
		
		JTextField tf1 = new JTextField("Drag Me", 10);
		tf1.setTransferHandler(th);
		JTextField tf2 = new JTextField(10);
		tf2.setTransferHandler(th);
		
		tf1.setDragEnabled(true);
		
		contentPane.setLayout(new GridLayout(2,2));
		contentPane.add(new JLabel("Text Field (Drag enabled): "));
		contentPane.add(tf1);
		contentPane.add(new JLabel("Text Field (Drag not enabled): "));
		contentPane.add(tf2);
		
		pack();
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	public static void main(String[] args) {
		new SimpleDragDropTest();
	}
}
